﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ticTacToe.Models
{
    
    /**
     * Stub class to imitate game service  for Testing against the Gui
     * 
     */
    public class GameServiceStub
    {
        public char nextGameMark;
        public char[] board = new char[9];

        
        private int randomGenerator(int minValue, int maxValue)
        {
            Random r = new Random();
            return r.Next(minValue, maxValue + 1);
        }

        public GameModel check(int square, char mark) {
            board[square] = mark;  
            GameModel gm = new GameModel();
            if (mark == 'X')
            {
                gm.nextMove = 'O';
            }
            else {
                gm.nextMove = 'X';
            }
            return gm;
        }

        public void computerplay(int square) {
            int response = -1;
            do
            {
                response = randomGenerator(0, 9);
            } while (response == square);
        
        }

        public GameModel getCustom(int square, char mark)
        {
            GameModel gm = new GameModel();
           
            gm.board[0] = 'X';
            gm.board[1] = 'O';
            gm.board[2] = 'E';
            gm.board[3] = 'E';
            gm.board[4] = 'O';
            gm.board[5] = 'E';
            gm.board[6] = 'X';
            gm.board[7] = 'O';
            gm.board[8] = 'X';
            gm.board[square] = mark;
            
            
            
            if (mark == 'X')
            {
                gm.nextMove = 'O';
            }
            else {
                gm.nextMove = 'X';
            }
            gm.gameId = "3a56g78f3c";
            gm.message = "X";
            gm.winningRow = "2;dia;XXX";

            return gm;
        }

    }
}
